Release 10.1A: OpenEdge Development:
ProDataSets
ProDataSet change events
There are events that you can define for the process of making local changes to the records in a ProDataSet.
The mechanism for defining change events is exactly the same as for defining
FILLevents. You use theSET-CALLBACK-PROCEDUREmethod to associate an internal procedure name and the handle of an active procedure instance containing that internal procedure with a fixed event name. Since these are events that occur when the temp-tables themselves are modified whileTRACKING-CHANGESis true, it is reasonable that the event procedure could be located either on the client side or on the server side of a distributed application, depending on whether the temp-tables are being changed by user actions on the client or by other business logic actions on the server. Note that there are no distributed calls to event procedures. Progress will not automatically run an event in a server-side procedure from the client. The expectation is that if the temp-table is changed on the client, then the supporting event logic is running on the client. The application can, of course, make its own calls from the client event procedures to procedures on the server, but you must consider the expense of doing this and avoid it wherever possible.In every case the event procedure receives the ProDataSet object as an
INPUTparameter, just asFILLevents do. The event procedure can define the parameter asDATASETor asDATASET-HANDLE, depending on whether it has a static definition of the ProDataSet. All of these events are defined on a temp-table buffer, not the ProDataSet itself. That is, theSET-CALLBACK-PROCEDUREmethod is executed on a temp-table buffer handle.Event procedures are defined for create and delete events. There is no support for a modify event. This section uses the general term “change statement” to refer to any language statement that causes one of these events. The event procedures all have access to the before images of changed or deleted records using the attributes described earlier.
Progress supports the following events for ProDataSet row-level changes:
ROW-CREATE— This is fired on aCREATEtemp-tablestatement, after the record is created in the temp-table. The current buffer for the temp-table is available and contains initial values as defined in the temp-table definition (or inherited from the schema). This event could be used to calculate other initial values for other fields or to make changes to other records (such as to update a child record count in some parent record). You could also reject the create by deleting the new temp-table record. This will cause it to be expunged from the before-table as well as the after-table. AnyCREATEtrigger procedure is executed after this event is handled.ROW-DELETE— This is fired on aDELETEtemp-tablestatement, before the record is deleted. The event procedure could use this event toRETURN NO-APPLYto cancel the delete or to make adjustments to other records based on the delete (such as updating totals in other records). Since the record has not yet been deleted, the record is in the temp-table buffer and the code can look at its values. This event fires only after Progress has verified that the delete operation is valid, for example, that there is a record in the buffer to delete. Therefore the event code can assume that the delete will go through unless cancelled by the event procedure itself, and can take actions based on the record deletion while the record is still there to be looked at. AnyDELETEtrigger procedure is executed after this event is handled.ROW-UPDATE— This is fired immediately before the record is updated in the temp-table. It typically occurs when the buffer scope ends, the transaction scope ends, theRELEASEstatement orBUFFER-RELEASE( )method is run on the buffer, or the buffer is needed for another record. Progress sets theSELFsystem handle to the handle of the buffer on which the event procedure is running before calling the event handler. If the event handler returnsNO-APPLYorERROR, the return is ignored. The handler has run, and it is too late to undo any changes to the record. You can use this event to determine if and how a record has changed by reading the buffer in the before-image table (using theSELF:BEFORE-ROWIDattribute) and comparing it to the updated buffer. You can also use this event in the event handler to update fields in the record (for example, to supply a calculated field). You cannot read another record into the buffer on which the event procedure is running in the event handler. If you need to read another record, use a different buffer to avoid disturbing the record you are currently updating.If you
RETURNERROR, this raises the Progress error condition as it does elsewhere. You can also set theERROR-STRINGattribute of a row yourself to signal an error internally.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |